<%--
  Created by IntelliJ IDEA.
  User: bin.liu
  Date: 2018/12/5
  Time: 16:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<jsp:include page="/pages/sysIndex/default.jsp"/>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-trophy"></i>工艺列表
            </div>
            <div class="box-tools pull-right">
                <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
                <sec:authorize access="hasRole('ROLE_ENTERPRISE_MAINTAINING_MAINTAIN_TECHNOLOGY_EDIT')">
                    <a href="javascript:;" onclick="vLayuiUtil.openLayerMaxWindow('wFacility', '<c:url
                            value="/web/admin/inspectionTechnology/importPage.action"/>','批量导入')" class="btn btn-default btnTool"
                       title="新增用户"><i class="fa fa-plus"></i> 批量导入</a>
                    <a href="javascript:;" onclick="vLayuiUtil.openLayerMaxWindow('wInspectionTechnology',
                            '<c:url value="/web/admin/inspectionTechnology/editPage.action"/>','新增工艺')" class="btn btn-default btnTool" title="新增"><i class="fa fa-plus"></i> 新增</a>
                    <a href="javascript:;" onclick="copyEdit()"
                       class="btn btn-default btnTool" title="复制新增"><i class="fa fa-plus"></i> 复制新增</a>
                </sec:authorize>

            </div>
        </div>

        <div class="box-body">
            <form id="searchForm" action="<c:url value="/web/admin/inspectionTechnology/listJson.action"/>" method="post" class="form-inline hide" data-page-no="1" data-page-size="20" data-order-by="">
                <div class="form-group">
                    <label class="control-label">工艺巡检名称：</label>
                    <div class="control-inline">
                        <input type="text" id="searchName" name="searchName" value="" maxlength="64" class="form-control width-120">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">工艺流水号：</label>
                    <div class="control-inline">
                        <input type="text" id="searchCode" name="searchCode" value="" maxlength="64" class="form-control width-120">
                    </div>
                </div>

                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">查询</button>
                    <button type="reset" class="btn btn-default btn-sm">重置</button>
                </div>
            </form>

            <table id="dataGrid"></table>
            <div id="dataGridPage"></div>
        </div>

    </div>
</div>
<script>
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        showCheckbox: true,
        columnModel: [
            <sec:authorize access="hasRole('ROLE_ENTERPRISE_MAINTAINING_MAINTAIN_TECHNOLOGY_EDIT')">
            {
                header: '操作',
                name: 'actions',
                width: 100,
                align: "center",
                sortable: false,
                title: false,
                formatter: function (val, obj, row, act) {
                    var editUrl='<c:url value="/web/admin/inspectionTechnology/editPage.action?id="/>'+row.id;
                    return '<a href="javascript:;" class="btn btn-default btn-xs btnList" onclick="vLayuiUtil.openLayerMaxWindow(\'wInspectionTechnology\', \''+editUrl+'\',\'编辑\')"><i class="fa fa-pencil">编辑</i></a>&nbsp;'+
                        '<a href="javascript:;" class="btn btn-default btn-xs btnList" onclick=" submitRemove(\'' + row.id + '\', \'0\')"><i class="fa fa-trash-o"></i>删除</a>&nbsp;';
                }
            },
            </sec:authorize>
            {header:'流水号', name:'code', index:'code', width:100, align:"center",sortable: false},
            {header:'所属专业', name:'rootCatName', index:'facilityCat', width:100, align:"center",sortable: false},
            {header:'设备类别', name:'facilityCatName', index:'facilityCat', width:100, align:"center",sortable: false},
            {header:'工艺巡检名称', name:'name', index:'name', width:100, align:"center",sortable: false},
            {header:'所属部门', name:'organizationName', index:'organization', width:100, align:"center",sortable: false},
            {header:'预计工时(分)', name:'estimateTime', index:'estimateTime', width:100, align:"center",sortable: false},
            {header:'技能要求', name:'requireSkill', index:'requireSkill', width:100, align:"center",sortable: false},
            {header:'所属企业', name:'enterpriseName', index:'enterprise', width:100, align:"center",sortable: false}
        ],
        // 加载成功后执行事件
        ajaxSuccess: function(data){

        }
    });
</script>
<script>
    function submitRemove(id) {
        js.confirm('你确认要删除这条数据吗？', function () {
            $.ajax({
                type: 'post',
                url: "<c:url value="/web/admin/inspectionTechnology/delete.action" />",
                data: {"id": id},
                dataType: 'json',
                async: false,
                success: function (data) {
                    js.showMessage(data.msg);
                    $('#dataGrid').dataGrid('refresh');
                },
                error: function () {
                    js.showMessage("出错了，请联系管理员");
                }
            });
        })
    }

    function copyEdit() {
        var ids = $("#dataGrid").jqGrid("getGridParam", "selarrrow");
        if (ids.length == 0) {
            js.showMessage("请选择要复制的工艺信息");
            return false;
        }
        if (ids.length > 1) {
            js.showMessage("只能选择一条工艺信息操作");
            return false;
        }
        vLayuiUtil.openLayerMaxWindow('wInspectionTechnology','<c:url
                            value="/web/admin/inspectionTechnology/copyEditPage.action?id="/>'+ids,'复制新增')
    }
</script>